package main

import (
	"fmt"
	"reflect"
)

/*
   type Name
	 type Kind
*/

func reflectFn(x interface{}) {
	v := reflect.TypeOf(x)
	v.Name() //类型名称
	v.Kind() //类型种类
	fmt.Printf("类型名称：%v,类型种类：%v\n", v.Name(), v.Kind())
}

type People struct {
	Name string
	Age  int
}

type myInt int

func main() {

	var a myInt = 33

	reflectFn(a) //类型名称：myInt,类型种类：int

	var p = People{
		Name: "张三",
		Age:  33,
	}
	reflectFn(p) //类型名称：People,类型种类：struct

	var b *int
	reflectFn(b) //类型名称：,类型种类：ptr   指针没有类型名称

	var c = [3]string{"11", "22", "33"}
	reflectFn(c) //类型名称：,类型种类：array

	var d = []int{1, 2, 3, 4}
	reflectFn(d) //类型名称：,类型种类：slice
}
